import time

def file_reader(filename):
	file = open(filename, 'r')
	data = list(map(int, file.readlines()))
	return data

def bsort(file_text):
	back = True
	while back:
		back = False
		for i in range(len(file_text)-1):
			if file_text[i] > file_text[i+1]:
				file_text[i], file_text[i+1] = file_text[i+1], file_text[i]
				back = True
		
	return file_text


file1 = file_reader('m1_sorted.txt')
file2 = file_reader('m2_reverse.txt')
file3 = file_reader('m3_shuffle.txt')


time_start = time.perf_counter()
bsort(file1)
time_finish = time.perf_counter()
print('m1_sorted.txt: ' + str(time_finish-time_start))


time_start = time.perf_counter()
bsort(file2)
time_finish = time.perf_counter()
print('m2_reverse.txt: ' + str(time_finish-time_start))


time_start = time.perf_counter()
bsort(file3)
time_finish = time.perf_counter()
print('m3_shuffle.txt: ' + str(time_finish-time_start))
